﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Security.Cryptography;
using Traceability.Domain;
using Traceability.Service.Interfae;

namespace RBACDuYaJun.Api.Controllers
{
    /// <summary>
    /// 深加工信息/原料信息/辅料信息/添加剂信息/包材信息/深加工企业信息
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessdsController : ControllerBase
    {
        /// <summary>
        /// 深加工服务
        /// </summary>
        private readonly IProcessdService _processdService;
        /// <summary>
        /// 原料信息服务
        /// </summary>
        private readonly IRawService _rwService;
        /// <summary>
        /// 辅料信息服务
        /// </summary>
        private readonly IAuxiliaryService _auxiliaryService;
        /// <summary>
        /// 添加剂服务
        /// </summary>
        private readonly IAdditiveService _additiveService;
        /// <summary>
        /// 包材服务
        /// </summary>
        private readonly IPackagingService _packagingService;
        /// <summary>
        /// 深加工企业服务
        /// </summary>
        private readonly IDeepEnterprisService _deepEnterprisService;
        public ProcessdsController(IProcessdService processdService, IRawService rwService, IAuxiliaryService auxiliaryService, 
            IAdditiveService additiveService, IPackagingService packagingService, IDeepEnterprisService deepEnterprisService)
        {
            _processdService = processdService;
            _rwService = rwService;
            _auxiliaryService = auxiliaryService;
            _additiveService = additiveService;
            _packagingService = packagingService;
            _deepEnterprisService=deepEnterprisService;
        }

        /// <summary>
        /// 添加深加工信息
        /// </summary>
        /// <param name="processd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddProcess(Processd processd)
        {
           return await _processdService.AddProcess(processd);
        }
       
        /// <summary>
        /// 显示深加工信息
        /// </summary>
        /// <param name="bacth"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Processd>> GetProcessdsList(int pid)
        {
            return await _processdService.GetProcessdsList(pid);
        }
        /// <summary>
        /// 修改深加工信息
        /// </summary>
        /// <param name="processd"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> UpdateProcced(Processd processd)
        {
           return await _processdService.UpdateProcced(processd);
        }
        /// <summary>
        /// 添加原料
        /// </summary>
        /// <param name="raw"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddRaw(Raw raw)
        {
            return await _rwService.AddRaw(raw);
        }
        /// <summary>
        /// 反填原料信息
        /// </summary>
        /// <param name="RawId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Raw>> GetRawdBy(string bath)
        {
           return await _rwService.GetRawdBy(bath);
        }
        /// <summary>
        /// 显示原料信息
        /// </summary>
        /// <param name="bacth"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Raw>> GetRawList(int rid)
        {
           return await _rwService.GetRawList(rid);
        }
        /// <summary>
        /// 修改原料信息
        /// </summary>
        /// <param name="raw"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateRaw(Raw raw)
        {
          return await _rwService.UpdateRaw(raw);
        }
        /// <summary>
        /// 添加辅料信息
        /// </summary>
        /// <param name="auxiliary"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddAuxiliary(Auxiliary auxiliary)
        {
            return await _auxiliaryService.AddAuxiliary(auxiliary);
        }
        /// <summary>
        /// 反填辅料信息
        /// </summary>
        /// <param name="AuxiliaryId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Auxiliary>> GetAuxiliaryBy(string bath)
        {
           return await _auxiliaryService.GetAuxiliaryBy(bath);
        }
        /// <summary>
        /// 显示辅料信息
        /// </summary>
        /// <param name="bacth"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Auxiliary>> GetAuxiliaryList(int tid)
        {
            return await _auxiliaryService.GetAuxiliaryList(tid);
        }
        /// <summary>
        /// 修改辅料信息
        /// </summary>
        /// <param name="auxiliary"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateAuxiliary(Auxiliary auxiliary)
        {
           return await _auxiliaryService.UpdateAuxiliary(auxiliary);
        }
        /// <summary>
        /// 添加添加剂信息
        /// </summary>
        /// <param name="additive"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> CreateAdditives(Additive additive)
        {
          return await _additiveService.CreateAdditives(additive);
        }
        /// <summary>
        /// 反填添加剂信息
        /// </summary>
        /// <param name="AdditiveId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Additive>> GetAdditiveBy(string  bath)
        {
           return await _additiveService.GetAdditiveBy(bath);
        }
        /// <summary>
        /// 显示添加剂信息
        /// </summary>
        /// <param name="bacth"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Additive>> GetAdditiveList(int tid)
        {
           return await _additiveService.GetAdditiveList(tid);
        }
        /// <summary>
        ///修改添加剂信息
        /// </summary>
        /// <param name="additive"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateAdditive(Additive additive)
        {
            return await _additiveService.UpdateAdditive(additive);
        }
        /// <summary>
        /// 添加包材信息
        /// </summary>
        /// <param name="packaging"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> CreatePackaging(Packaging packaging)
        {
            return await _packagingService.CreatePackaging(packaging);
        }
        /// <summary>
        /// 反填包材信息
        /// </summary>
        /// <param name="Packagingid"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Packaging>> GetPackagingBy(string bath)
        {
           return await _packagingService.GetPackagingBy(bath);
        }
        /// <summary>
        /// 显示包材信息
        /// </summary>
        /// <param name="bacth"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Packaging>> GetPackagingList(int tid)
        {
           return await _packagingService.GetPackagingList(tid);
        }
        /// <summary>
        /// 修改包材信息
        /// </summary>
        /// <param name="packaging"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdatePackaging(Packaging packaging)
        {
           return await _packagingService.UpdatePackaging(packaging);
        }
        /// <summary>
        /// 添加深加工企业信息
        /// </summary>
        /// <param name="deepEnterprises"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> CreateDeepEnterpris(DeepEnterprises deepEnterprises)
        {
            return await _deepEnterprisService.CreateDeepEnterpris(deepEnterprises);
        }
        /// <summary>
        /// 反填深加工企业信息
        /// </summary>
        /// <param name="DeepEnterprisesId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<DeepEnterprises> GetDeepEnterprisesBy(int DeepEnterprisesId)
        {
            return await _deepEnterprisService.GetDeepEnterprisesBy(DeepEnterprisesId);
        }
        /// <summary>
        /// 显示深加工企业信息
        /// </summary>
        /// <param name="bacth"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<DeepEnterprises>> GetDeepEnterprisesList(string bacth)
        {
            return await _deepEnterprisService.GetDeepEnterprisesList(bacth);
        }
        /// <summary>
        /// 修改深加工企业信息
        /// </summary>
        /// <param name="deepEnterprises"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateDeepEnterprises(DeepEnterprises deepEnterprises)
        {
            return await _deepEnterprisService.UpdateDeepEnterprises(deepEnterprises);
        }
    }
}
